<?php
class BksController extends AppController {

	var $name = 'Bks';
	var $helpers = array('Html', 'Form');
    
    var $paginate = array(                        
                        'limit' => 25,
                        'order' => array(
                            'Bk.date_bk' => 'desc'
                        )
                    );

	function index() {
		$this->Bk->recursive = 0;
		$this->set('bks', $this->paginate());
	}
    function index_bayden() {
		$this->Bk->recursive = 0;
		$this->set('bks', $this->paginate());
	}
    
    function index_nhst() {
		$this->Bk->recursive = 0;
		$this->set('bks', $this->paginate());
	}
    function index_phieudt() {
		$this->Bk->recursive = 0;
		$this->set('bks', $this->paginate());
	}
    
    function index_sd_tt(){
		$this->Bk->recursive = 0;
		$this->set('bks', $this->paginate());
	}
	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Bk.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('bk', $this->Bk->read(null, $id));
	}



	function add() {
		if (!empty($this->data)) {
			$this->Bk->create();
			if ($this->Bk->save($this->data)) {
				$this->Session->setFlash(__('The Bk has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Bk could not be saved. Please, try again.', true));
			}
		}
		$canbos = $this->Bk->Canbo->find('list');
		$this->set(compact('canbos'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Bk', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Bk->save($this->data)) {
				$this->Session->setFlash(__('The Bk has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Bk could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Bk->read(null, $id);
		}
		$canbos = $this->Bk->Canbo->find('list');
		$this->set(compact('canbos'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Bk', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Bk->del($id)) {
			$this->Session->setFlash(__('Bk deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>